#ifndef _GUI_ENTRY_H
#define _GUI_ENTRY_H

#include<stddef.h>
#include<stdbool.h>
#include"gui_spirit.h"
#include"gui_color.h"

typedef enum 
{
    GUI_ENTRY_CURSOR_LEFT_TO_RIGHT, 
    GUI_ENTRY_CURSOR_RIGHT_TO_LEFT,
    GUI_ENTRY_CURSOR_BOTTOM_TO_TOP,
    GUI_ENTRY_CURSOR_TOP_TO_BUTTON,
}gui_entry_cursor_orientation_t;

typedef struct 
{
    gui_spirit_t spirit;
    bool editable;
    bool visiable;
    char invisable_char;
    bool focus;

    gui_surface_t *selection; //selete area
    int cursor_pos; //cursor position
    gui_color_t focus_color; 
    gui_color_t unfocus_color;
    int select_start_pos; //select start pos
    int select_end_pos; //select end pos
    int start_selecting;  //in selecting status
}gui_entry_t; 

#define GUI_ENTRY(spirit) ((gui_entry_t*)(spirit))

#define GUI_ENTRY_WIDTH_DEFAULT 100
#define GUI_ENTRY_HIEGHT_DEFAULT 20

#define GUI_ENTRY_FOCUS_COLOR GUI_RGB(255,255,255)

#define GUI_ENTRY_INVISABLE_CHAR_DEFAULT '*'


gui_spirit_t *gui_entry_create();
void gui_entry_set_max_length(gui_entry_t *entry, int max);
void gui_entry_set_text(gui_entry_t *entry,const char *text);
const char *gui_entry_get_text(gui_entry_t *entry);
void gui_entry_set_editable(gui_entry_t *entry, bool is_editable);
bool gui_entry_get_editable(gui_entry_t *entry);
void gui_entry_set_visiable(gui_entry_t *entry, bool is_visiable);
bool gui_entry_get_visiable(gui_entry_t *entry);
void gui_entry_set_invisiable_char(gui_entry_t *entry, char ch);
void gui_entry_unset_invisiable_char(gui_entry_t *entry);
void gui_entry_move_cursor(gui_entry_t *entry, gui_entry_cursor_orientation_t orientation, int step);
void gui_entry_set_focus(gui_entry_t *entry, bool is_focus);
bool gui_entry_get_focus(gui_entry_t *entry);
int gui_entry_locate_position(gui_entry_t *entry, int position);
void gui_entry_set_position(gui_entry_t *entry, int position);
int gui_entry_get_position(gui_entry_t *entry);
void gui_entry_insert_text(gui_entry_t *entry, const char *new_text, int new_text_length);
void gui_entry_delete_text(gui_entry_t *entry, int start_pos, int end_pos);
void gui_entry_process_key(gui_entry_t *entry, int keycode, int modify);
void gui_entry_select_region(gui_entry_t *entry,int start_pos,int end_pos);
bool gui_entry_get_selection_bounds(gui_entry_t *entry,int *start_pos,int *end_pos);
void gui_entry_reset_selection(gui_entry_t *entry,int position);
void gui_entry_mouse_motion(gui_entry_t *entry,int position);
void gui_entry_mouse_press(gui_entry_t *entry,int position);
void gui_entry_mouse_release(gui_entry_t *entry);



#endif